﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Library.DbObjects.Factory;
using Library.Interface;

namespace NameplateReport
{
    public partial class HomeForm : Form, INamePlateManager
    {
        BaseObjectFactory Instance = new BaseObjectFactory();
        private BindingSource bindingSource1 = new BindingSource();
        private SearchNamePlate _searchNamePlate = new SearchNamePlate();
        private ModifyNamePlate _modifyNamePlate = new ModifyNamePlate();
        public HomeForm()
        {
            InitializeComponent();
            _searchNamePlate.INamePlateManager = this;
            _modifyNamePlate.INamePlateManager = this;
        }

        private void HomeForm_Load(object sender, EventArgs e)
        {
            lblTitle.Text = "List of Nameplates";
            pnContainer.Controls.Add(_searchNamePlate);
        }

        public bool Add()
        {
            pnContainer.Controls.Clear();
            pnContainer.Controls.Add(_modifyNamePlate);
            return true;
        }

        public bool Edit(IBaseObject nameplate)
        {
            pnContainer.Controls.Clear();
            _modifyNamePlate.NamePlate = nameplate;
            pnContainer.Controls.Add(_modifyNamePlate);
            return true;            
        }

        public bool Delete(IList<IBaseObject> nameplates)
        {
            return true;

        }

        public void Cancel(object sender)
        {
            if (ReferenceEquals(_modifyNamePlate, sender))
            {
                pnContainer.Controls.Clear();
                pnContainer.Controls.Add(_searchNamePlate);
            }
        }
    }
}
